package com.ruoyi.generator.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;

import com.ruoyi.generator.domain.InstitutionVo;
//import com.ruoyi.generator.domain.Province;
import com.ruoyi.generator.service.InstitutionService;
import com.ruoyi.generator.service.IProvinceService;
import com.ruoyi.generator.service.InstitutionServiceImpl;
import com.ruoyi.system.service.ISysDictDataService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.generator.domain.Institution;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

@RestController
public class InstitutionController extends BaseController {
    @Autowired
    InstitutionService institutionService;

    @Autowired
    IProvinceService provinceService;
    @Autowired
    ISysDictDataService sysDictDataService;

    @GetMapping("/institutionlistPage")
    public TableDataInfo list(Institution institution)
    {
        startPage();
        List<Institution> list = institutionService.getInstitutionList(institution);
//        Map<String, Long> collect = list.stream().collect(Collectors.groupingBy(x -> x.getProvinceId(), Collectors.counting()));
//        System.out.println(collect);


        return getDataTable(list);
    }

    public static void main(String[] args) {
        InstitutionService institutionService =new InstitutionServiceImpl() ;
        List<Institution> list = institutionService.getInstitutionList(new Institution());

        Map<String, List<Institution>> collect = list.stream().collect(Collectors.groupingBy(x -> x.getProvinceId()));
        System.out.println(collect);

    }


}
